<template>
  <span class="box">
    <img src="../assets/imgs/2.jpg" alt="" />
    <p @click="btn" :style="{ backgroundColor: colorstr }">
      {{ title }}}
    </p>
  </span>
</template>

<script>
export default {
  props: ["title"],
  data() {
    return {
      colorstr: "",
    };
  },
  methods: {
    btn() {
      this.colorstr = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
      
    },
  },
};
</script>

<style scoped>
.box {
  display: inline-block;
  width: 400px;
  height: 400px;
  border: 1px solid #222;
  margin: 10px;
}
img {
  width: 100%;
}
</style>